package com.wr.springbootsss.config;

import com.wr.springbootsss.interceptor.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

/**
 * @author 王瑞
 * @description: 自定义拦截器
 * @date 2020/3/11  15:06
 */

//配置自定义拦截器 需要实现WebMvcConfigurer接口
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    //注入自定义放入拦截器类
    @Autowired
    private MyInterceptor myInterceptor;


    //注册自定义拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //设置需要拦截的路径   以及排除登录页面的拦截
        registry.addInterceptor(myInterceptor).addPathPatterns("/**").excludePathPatterns("/login/**");
    }
}
